fix bug 'vector iterator + offset out of range' in nnet-common#2594
fix bug 'vector iterator + offset out of range' in nnet-common#2594danpovey merged 2 commits intokaldi-asr:masterfrom
Conversation
src/nnet3/nnet-common.cc
Outdated
| // check 'n2 > index_vector.size()' first, | ||
| // otherwise, 'end - n2' will be less than 'index_vector.begin()' and | ||
| // cause error "vector iterator + offset out of range" in STL vector. | ||
| if (n2 > index_vector.size() || iter >= end - n2) |
There was a problem hiding this comment.
make 'size' a variable (declare it next to 'ans') as it's inefficient to keep using size() in a loop.
There was a problem hiding this comment.
updated! Define 'len' as 'index_vector.size()'. Pls review again. Thanks!
b1ff84f to
1df9cc1
Compare
src/nnet3/nnet-common.cc
Outdated
| ans += iter->x * 89809; | ||
| // check 'n2 > index_vector.size()' first, | ||
| // otherwise, 'end - n2' will be less than 'index_vector.begin()' and | ||
| // cause error "vector iterator + offset out of range" in STL vector. |
There was a problem hiding this comment.
Please make sure this code is correctly indented (and make sure you use spaces not tabs).
Also, you can change the comment to the following:
// The following if-statement was introduced in order to fix an
// out-of-range iterator problem on Windows.
src/nnet3/nnet-common.cc
Outdated
| std::vector<Index>::const_iterator iter = index_vector.begin(), | ||
| end = index_vector.end(), med = end; | ||
| if (med > iter + n1) | ||
| if (n1 <= len) |
There was a problem hiding this comment.
.. also I believe this should be if n1 < len, not <=.
There was a problem hiding this comment.
updated again. Also checked indentation and spaces. With another question:
why when med == end == iter + n1, we would like to do for (; iter != med; ++iter) instead of skip this? This will make the hash better?
bf2f017 to
43eeb9a
Compare
43eeb9a to
68d847d
Compare
…ng/limit_arpa_unk_history.py [src] Correct usage message of acc-lda (kaldi-asr#2598) [scripts] RNNLM script fix: to accept successive spaces in configs (etc.) kaldi-asr#2595 (kaldi-asr#2597) [scripts] Slight cleanup in lmrescore_rnnlm_lat.sh (kaldi-asr#2554) [src] Fix Windows out-of-range iterator issue for nnet3 (kaldi-asr#2594) [src] Update Windows installation instructions (kaldi-asr#2607) [egs] Fix to LibriSpeech download script [affects 2nd run] (kaldi-asr#2611) [src] Change RNNLM test program to clean up temporary file (kaldi-asr#2610) added a script to scale arcs which output <unk> in HCLG.fst fix fix updating results and cleaning up scripts, and fixed a bug in utils/lang/limit_arpa_unk_history.py [scripts] Fix to script usage message (kaldi-asr#2601) [src] Correct usage message of acc-lda (kaldi-asr#2598) [scripts] RNNLM script fix: to accept successive spaces in configs (etc.) kaldi-asr#2595 (kaldi-asr#2597) [scripts] Slight cleanup in lmrescore_rnnlm_lat.sh (kaldi-asr#2554) [src] Fix Windows out-of-range iterator issue for nnet3 (kaldi-asr#2594) [src] Update Windows installation instructions (kaldi-asr#2607) [egs] Fix to LibriSpeech download script [affects 2nd run] (kaldi-asr#2611) [src] Change RNNLM test program to clean up temporary file (kaldi-asr#2610)
No description provided.